/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "orden_compra_cab", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrdenCompraCab.findAll", query = "SELECT o FROM OrdenCompraCab o"),
    @NamedQuery(name = "OrdenCompraCab.findByIdordenCompra", query = "SELECT o FROM OrdenCompraCab o WHERE o.idordenCompra = :idordenCompra"),
    @NamedQuery(name = "OrdenCompraCab.findByFecha", query = "SELECT o FROM OrdenCompraCab o WHERE o.fecha = :fecha"),
    @NamedQuery(name = "OrdenCompraCab.findByEstado", query = "SELECT o FROM OrdenCompraCab o WHERE o.estado = :estado")})
public class OrdenCompraCab implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idorden_compra", nullable = false)
    private Integer idordenCompra;
    @Column(name = "fecha")
    private Integer fecha;
    @Column(name = "estado")
    private Integer estado;
    @JoinTable(name = "pedido_orden", joinColumns = {
        @JoinColumn(name = "idorden_compra", referencedColumnName = "idorden_compra", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "idpedido_cab", referencedColumnName = "idpedido_cab", nullable = false)})
    @ManyToMany
    private Collection<PedidoCab> pedidoCabCollection;
    @ManyToMany(mappedBy = "ordenCompraCabCollection")
    private Collection<Productos> productosCollection;
    @JoinColumn(name = "idproveedores", referencedColumnName = "idproveedores", nullable = false)
    @ManyToOne(optional = false)
    private Proveedores idproveedores;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ordenCompraCab")
    private Collection<OrdenCompra> ordenCompraCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ordenCompra")
    private Collection<PedidoCab> pedidoCabCollection1;

    public OrdenCompraCab() {
    }

    public OrdenCompraCab(Integer idordenCompra) {
        this.idordenCompra = idordenCompra;
    }

    public Integer getIdordenCompra() {
        return idordenCompra;
    }

    public void setIdordenCompra(Integer idordenCompra) {
        this.idordenCompra = idordenCompra;
    }

    public Integer getFecha() {
        return fecha;
    }

    public void setFecha(Integer fecha) {
        this.fecha = fecha;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    @XmlTransient
    public Collection<PedidoCab> getPedidoCabCollection() {
        return pedidoCabCollection;
    }

    public void setPedidoCabCollection(Collection<PedidoCab> pedidoCabCollection) {
        this.pedidoCabCollection = pedidoCabCollection;
    }

    @XmlTransient
    public Collection<Productos> getProductosCollection() {
        return productosCollection;
    }

    public void setProductosCollection(Collection<Productos> productosCollection) {
        this.productosCollection = productosCollection;
    }

    public Proveedores getIdproveedores() {
        return idproveedores;
    }

    public void setIdproveedores(Proveedores idproveedores) {
        this.idproveedores = idproveedores;
    }

    @XmlTransient
    public Collection<OrdenCompra> getOrdenCompraCollection() {
        return ordenCompraCollection;
    }

    public void setOrdenCompraCollection(Collection<OrdenCompra> ordenCompraCollection) {
        this.ordenCompraCollection = ordenCompraCollection;
    }

    @XmlTransient
    public Collection<PedidoCab> getPedidoCabCollection1() {
        return pedidoCabCollection1;
    }

    public void setPedidoCabCollection1(Collection<PedidoCab> pedidoCabCollection1) {
        this.pedidoCabCollection1 = pedidoCabCollection1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idordenCompra != null ? idordenCompra.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdenCompraCab)) {
            return false;
        }
        OrdenCompraCab other = (OrdenCompraCab) object;
        if ((this.idordenCompra == null && other.idordenCompra != null) || (this.idordenCompra != null && !this.idordenCompra.equals(other.idordenCompra))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.OrdenCompraCab[ idordenCompra=" + idordenCompra + " ]";
    }
    
}
